from pyfbsdk import *
from pyfbsdk_additions import *
from sys import *
import os
import traceback
global lFp
lFp = FBFilePopup()
def BrowseCallback(control, event):
lFp.Caption = "Select the shot track definition file:"
lFp.Style = FBFilePopupStyle.kFBFilePopupOpen
lFp.Filter = "*.txt"
if os.path.isdir(os.path.splitext(traceback.extract_stack()[-1][0])[0]):
lFp.Path = os.path.normpath(os.path.splitext(traceback.extract_stack()[-1][0])[0])
else:
lFp.Path = os.path.normpath(os.path.dirname(traceback.extract_stack()[-1][0]))
lRes = lFp.Execute()
if lRes:
eButt.Text = os.path.join(lFp.Path,lFp.FileName)
def SetupCallback(control, event):
try:
f=open(os.path.join(lFp.Path,lFp.FileName), 'r')
shotInfoFile = f.readlines()
f.close()
shotCnt = len(shotInfoFile)
counter = 1
for shotInfo in shotInfoFile:
shots = shotInfo.split()
(shotName,shotStart,shotEnd) = shots
iShotStart = int(shotStart)
iShotEnd = int(shotEnd)
if shotInfoFile[0] == shotInfo:
completeShotStart = iShotStart
if shotInfoFile[shotCnt - 1] == shotInfo:
completeShotEnd = iShotEnd
lCam = FBCamera (shotName)
lCam.Visible = True
lCam.Show = True
lNull = FBModelNull (shotName + "_INT")
lCam.Interest = lNull
lTrackContainer = FBStory().RootEditFolder.Tracks
lastTrack=0
lTrack=None
for Track in lTrackContainer:
if Track.Label =="Shot Track 1":
lTrack=Track
clipStart = FBTime(0,0,0,iShotStart)
if lTrack:
lClip = FBStoryClip (lCam, lTrack, clipStart)
lClip.Start = FBTime(0,0,0,iShotStart)
lClip.Stop = FBTime(0,0,0,iShotEnd)
if lastTrack<iShotEnd: lastTrack=iShotEnd
if backPlate.State == 1:
if counter < 10:
vidPath = os.path.join(lFp.Path, "shot0"+str(counter)+".avi")
else:
vidPath = os.path.normpath(lFp.Path+"shot" + str(counter) +".avi")
lVid = FBVideoClip(vidPath)
if lVid.IsValid():
lCam.BackGroundMedia = lVid
counter = counter + 1
FBPlayerControl().LoopEnd=FBTime(0,0,0,lastTrack,0)
lPlayer = FBPlayerControl()
lPlayer.LoopStart = FBTime(0,0,0,completeShotStart)
lPlayer.ZoomWindowStart = FBTime(0,0,0,completeShotStart)
lPlayer.LoopStop = FBTime(0,0,0,completeShotEnd)
lPlayer.ZoomWindowStop = FBTime(0,0,0,completeShotEnd)
lModel = FBFindModelByName('SHOT_001')
lModel.Translation = FBVector3d(-10000, 145, 300)
lModel = FBFindModelByName('SHOT_001_INT')
lModel.Translation = FBVector3d(-10000, 0, 0)
lModel = FBFindModelByName('SHOT_002')
lModel.Translation = FBVector3d(-5000, 145, 300)
lModel = FBFindModelByName('SHOT_002_INT')
lModel.Translation = FBVector3d(-5000, 0, 0)
lModel = FBFindModelByName('SHOT_003')
lModel.Translation = FBVector3d(0, 145, 300)
lModel = FBFindModelByName('SHOT_003_INT')
lModel.Translation = FBVector3d(0, 0, 0)
lModel = FBFindModelByName('SHOT_004')
lModel.Translation = FBVector3d(5000, 145, 300)
lModel = FBFindModelByName('SHOT_004_INT')
lModel.Translation = FBVector3d(5000, 0, 0)
lModel = FBFindModelByName('SHOT_005')
lModel.Translation = FBVector3d(10000, 145, 300)
lModel = FBFindModelByName('SHOT_005_INT')
lModel.Translation = FBVector3d(10000, 0, 0)
lCameras = FBSystem().Scene.Cameras
for lCam in lCameras:
if lCam.Name == "Producer Perspective":
lCam.FarPlaneDistance = 40000
break
FBApplication().SwitchViewerCamera(FBCameraSwitcher().CurrentCamera)
except IOError:
FBMessageBox( "Cannot Continue", "Unable to read the shot track definition file you selected or you have not selected one.", "OK", None, None )
exit
def PopulateLayout(mainLyt):
l = FBLabel()
l.Caption = "Select the shot track definition file to use:"
l.Style = FBTextStyle.kFBTextStyleBold
l.WordWrap = True
x = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(300,FBAttachType.kFBAttachNone,"")
h = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("lab","lab", x, y, w, h)
mainLyt.SetControl("lab",l)
e = FBEdit()
e.ReadOnly = True
e.Text = ""
x2 = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"")
y2 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"lab")
w2 = FBAddRegionParam(220,FBAttachType.kFBAttachNone,"")
h2 = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("path","path", x2, y2, w2, h2)
mainLyt.SetControl("path",e)
b2 = FBButton()
b2.Caption = "Browse..."
b2.Justify = FBTextJustify.kFBTextJustifyCenter
x3 = FBAddRegionParam(225,FBAttachType.kFBAttachLeft,"path")
y3 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"lab")
w3 = FBAddRegionParam(57,FBAttachType.kFBAttachNone,"")
h3 = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("but","but", x3, y3, w3, h3)
mainLyt.SetControl("but",b2)
global eButt
eButt = e
b2.OnClick.Add(BrowseCallback)
cb = FBButton()
cb.Style = FBButtonStyle.kFBCheckbox
cb.Caption = "Add backplates to each shot"
x4 = FBAddRegionParam(60, FBAttachType.kFBAttachLeft, "")
y4 = FBAddRegionParam(5, FBAttachType.kFBAttachBottom, "path")
w4 = FBAddRegionParam(300,FBAttachType.kFBAttachNone,"")
h4 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("backp", "backp",x4,y4,w4,h4)
mainLyt.SetControl("backp",cb)
global backPlate
backPlate = cb
b3 = FBButton()
b3.Caption = "Setup Shots"
b3.Justify = FBTextJustify.kFBTextJustifyCenter
x5 = FBAddRegionParam(40,FBAttachType.kFBAttachLeft,"")
y5 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"backp")
w5 = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
h5 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("shots","shots", x5, y5, w5, h5)
mainLyt.SetControl("shots",b3)
b3.OnClick.Add(SetupCallback)
x6 = FBAddRegionParam(20,FBAttachType.kFBAttachRight,"shots")
y6 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"backp")
w6 = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
h6 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
def CreateTool():
global t
t = CreateUniqueTool("Shot Track Setup Tool")
t.StartSizeX = 300
t.StartSizeY = 143
PopulateLayout(t)
ShowTool(t)
CreateTool()